package com.xbh.management.task;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class ExportFactory implements ApplicationContextAware {
    public static ApplicationContext applicationContext;

    public static SuperExport getSuperExport(Class clazz, String titleName , String[] title, Integer[] titleLength, List list) {
        SuperExport superExport = (SuperExport) applicationContext.getBean(clazz);
        superExport.setTITLE(title);
        superExport.setTITLEName(titleName);
        superExport.setTITLELength(titleLength);
        superExport.setList(list);
        return superExport;
    }

    public static SuperExport getSuperExport1(Class clazz, String titleName , String[] title, Integer[] titleLength, IPage list) {
        SuperExport superExport = (SuperExport) applicationContext.getBean(clazz);
        superExport.setTITLE(title);
        superExport.setTITLEName(titleName);
        superExport.setTITLELength(titleLength);
        superExport.setList1(list);
        return superExport;
    }


    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;

    }
}
